/*
 * ConversionBO.java
 *
 * Created on April 1, 2007, 11:32 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Data;

/**
 *  Business Object Class for Conversions
 *  @author Grant Gordon
 */
public class ConversionBO extends RevenueSourceBO{
    
    private boolean dirty = false;
    private boolean alreadyInDB = false;
    private String id = "";
    private String type = "";
    private double quantity = 0;
    private double pricePerUnit = 0;
    private double discountPercent = 0;
    private double totalPrice = 0;
    private String completed = "N";
    private String notificationSent = "N";
    
    /**
     * Creates a new instance of ConversionBO
     * @param GUID id
     */
    public ConversionBO(String GUID) {
        this.id = GUID;
    }
    
    /**
     * Asks the object if it has been changed or not.
     * @return Boolean: true means the object needs to be written out
     * to the DB.  false means there has been no change.
     */
    public boolean isDirty() {
        return dirty;
    }
    
    /**
     * Flags or unflags this object as having been changed.
     * @param dirty Boolean, indicates how to flad the object.
     */
    public void setDirty(boolean dirty) {
        this.dirty = dirty;
    }
    
    /**
     * Asks the object if it is already in the DB
     * @return boolean: in DB or not in DB
     */
    public boolean isAlreadyInDB() {
        return alreadyInDB;
    }
    
    /**
     * Flags the object as already in the DB or not
     * @param alreadyInDB tells the method how to flag the object
     */
    public void setAlreadyInDB(boolean alreadyInDB) {
        this.alreadyInDB = alreadyInDB;
    }
    
    /**
     * Returns the type (Motion or Still) that this
     * conversion object is.
     * @return Motion or Still
     */
    public String getType() {
        return type;
    }
    
    /**
     * Sets the type (Motion or Still) this conversion
     * object is.
     * @param type Motion or Still
     */
    public void setType(String type) {
        this.dirty = true;
        this.type = type;
    }
    
    /**
     * Returns the quanitity (i.e. minutes/photos) for this
     * conversion object.
     * @return quantity Number of minutes/photos
     */
    public double getQuantity() {
        return quantity;
    }
    
    /**
     * Sets the number of minutes/photos for this conversion
     * @param quantity Number of minutes/photos
     */
    public void setQuantity(double quantity) {
        this.dirty = true;
        this.quantity = quantity;
    }
    
    /**
     * Returns the price per unit (minutes/photos) for this conversion
     * @return Price Per Unit
     */
    public double getPricePerUnit() {
        return pricePerUnit;
    }
    
    /**
     * Sets Price per unit for this conversion
     * @param pricePerUnit Price per unit to set
     */
    public void setPricePerUnit(double pricePerUnit) {
        this.dirty = true;
        this.pricePerUnit = pricePerUnit;
    }
    
    /**
     * Returns the percent discount based on quantity
     * @return discountPercent Discount percentage
     */
    public double getDiscountPercent() {
        return discountPercent;
    }
    
    /**
     * Sets the discount percentage for this conversion based on quantity
     * @param discountPercent the discount percent
     */
    public void setDiscountPercent(double discountPercent) {
        this.dirty = true;
        this.discountPercent = discountPercent;
    }
    
    /**
     * Returns the total price for this conversion
     * @return Total price
     */
    public double getTotalPrice() {
        return totalPrice;
    }
    
    /**
     * Sets the total price for this conversion
     * @param totalPrice Total price
     */
    public void setTotalPrice(double totalPrice) {
        this.dirty = true;
        this.totalPrice = totalPrice;
    }
    
    
    
    /**
     * Returns object Id
     * @return id
     */
    public String getId() {
        return id;
    }
    
    /**
     * Sets objet's Id
     * @param id GUID
     */
    public void setId(String id) {
        this.dirty = true;
        this.id = id;
    }
    
    /**
     * Asks the Conversion order if it's ready yet
     * @return Complete status
     */
    public String getCompleted() {
        return completed;
    }
    
    /**
     * Set's the order as completed or not
     * @param completed complete status
     */
    public void setCompleted(String completed) {
        this.dirty = true;
        this.completed = completed;
    }
    
    /**
     * Asks the Conversion order if there has been a notification
     * @return Notification sent Y/N
     */
    public String getNotificationSent() {
        return notificationSent;
    }
    
    /**
     * Set's the notification flag
     * @param notificationSent Y/N
     */
    public void setNotificationSent(String notificationSent) {
        this.dirty = true;
        this.notificationSent = notificationSent;
    }
    
    /**
     * calculates the price
     *
     */
    public void calculatePrice() {
        double price = (pricePerUnit * quantity) * discountPercent;
        super.setPrice(price);
        
    }
    
}
